Option Strict On
Option Explicit On 

Public Class UColor
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents chkColor As System.Windows.Forms.CheckBox
    Friend WithEvents btnColor As System.Windows.Forms.Button
    Friend WithEvents lblColor As System.Windows.Forms.Label
    Friend WithEvents picColor As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(UColor))
        Me.chkColor = New System.Windows.Forms.CheckBox
        Me.btnColor = New System.Windows.Forms.Button
        Me.lblColor = New System.Windows.Forms.Label
        Me.picColor = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'chkColor
        '
        Me.chkColor.AccessibleDescription = resources.GetString("chkColor.AccessibleDescription")
        Me.chkColor.AccessibleName = resources.GetString("chkColor.AccessibleName")
        Me.chkColor.Anchor = CType(resources.GetObject("chkColor.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.chkColor.Appearance = CType(resources.GetObject("chkColor.Appearance"), System.Windows.Forms.Appearance)
        Me.chkColor.BackgroundImage = CType(resources.GetObject("chkColor.BackgroundImage"), System.Drawing.Image)
        Me.chkColor.CheckAlign = CType(resources.GetObject("chkColor.CheckAlign"), System.Drawing.ContentAlignment)
        Me.chkColor.Dock = CType(resources.GetObject("chkColor.Dock"), System.Windows.Forms.DockStyle)
        Me.chkColor.Enabled = CType(resources.GetObject("chkColor.Enabled"), Boolean)
        Me.chkColor.FlatStyle = CType(resources.GetObject("chkColor.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.chkColor.Font = CType(resources.GetObject("chkColor.Font"), System.Drawing.Font)
        Me.chkColor.Image = CType(resources.GetObject("chkColor.Image"), System.Drawing.Image)
        Me.chkColor.ImageAlign = CType(resources.GetObject("chkColor.ImageAlign"), System.Drawing.ContentAlignment)
        Me.chkColor.ImageIndex = CType(resources.GetObject("chkColor.ImageIndex"), Integer)
        Me.chkColor.ImeMode = CType(resources.GetObject("chkColor.ImeMode"), System.Windows.Forms.ImeMode)
        Me.chkColor.Location = CType(resources.GetObject("chkColor.Location"), System.Drawing.Point)
        Me.chkColor.Name = "chkColor"
        Me.chkColor.RightToLeft = CType(resources.GetObject("chkColor.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.chkColor.Size = CType(resources.GetObject("chkColor.Size"), System.Drawing.Size)
        Me.chkColor.TabIndex = CType(resources.GetObject("chkColor.TabIndex"), Integer)
        Me.chkColor.Text = resources.GetString("chkColor.Text")
        Me.chkColor.TextAlign = CType(resources.GetObject("chkColor.TextAlign"), System.Drawing.ContentAlignment)
        Me.chkColor.Visible = CType(resources.GetObject("chkColor.Visible"), Boolean)
        '
        'btnColor
        '
        Me.btnColor.AccessibleDescription = resources.GetString("btnColor.AccessibleDescription")
        Me.btnColor.AccessibleName = resources.GetString("btnColor.AccessibleName")
        Me.btnColor.Anchor = CType(resources.GetObject("btnColor.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.btnColor.BackgroundImage = CType(resources.GetObject("btnColor.BackgroundImage"), System.Drawing.Image)
        Me.btnColor.Dock = CType(resources.GetObject("btnColor.Dock"), System.Windows.Forms.DockStyle)
        Me.btnColor.Enabled = CType(resources.GetObject("btnColor.Enabled"), Boolean)
        Me.btnColor.FlatStyle = CType(resources.GetObject("btnColor.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.btnColor.Font = CType(resources.GetObject("btnColor.Font"), System.Drawing.Font)
        Me.btnColor.Image = CType(resources.GetObject("btnColor.Image"), System.Drawing.Image)
        Me.btnColor.ImageAlign = CType(resources.GetObject("btnColor.ImageAlign"), System.Drawing.ContentAlignment)
        Me.btnColor.ImageIndex = CType(resources.GetObject("btnColor.ImageIndex"), Integer)
        Me.btnColor.ImeMode = CType(resources.GetObject("btnColor.ImeMode"), System.Windows.Forms.ImeMode)
        Me.btnColor.Location = CType(resources.GetObject("btnColor.Location"), System.Drawing.Point)
        Me.btnColor.Name = "btnColor"
        Me.btnColor.RightToLeft = CType(resources.GetObject("btnColor.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.btnColor.Size = CType(resources.GetObject("btnColor.Size"), System.Drawing.Size)
        Me.btnColor.TabIndex = CType(resources.GetObject("btnColor.TabIndex"), Integer)
        Me.btnColor.Text = resources.GetString("btnColor.Text")
        Me.btnColor.TextAlign = CType(resources.GetObject("btnColor.TextAlign"), System.Drawing.ContentAlignment)
        Me.btnColor.Visible = CType(resources.GetObject("btnColor.Visible"), Boolean)
        '
        'lblColor
        '
        Me.lblColor.AccessibleDescription = resources.GetString("lblColor.AccessibleDescription")
        Me.lblColor.AccessibleName = resources.GetString("lblColor.AccessibleName")
        Me.lblColor.Anchor = CType(resources.GetObject("lblColor.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblColor.AutoSize = CType(resources.GetObject("lblColor.AutoSize"), Boolean)
        Me.lblColor.Dock = CType(resources.GetObject("lblColor.Dock"), System.Windows.Forms.DockStyle)
        Me.lblColor.Enabled = CType(resources.GetObject("lblColor.Enabled"), Boolean)
        Me.lblColor.Font = CType(resources.GetObject("lblColor.Font"), System.Drawing.Font)
        Me.lblColor.Image = CType(resources.GetObject("lblColor.Image"), System.Drawing.Image)
        Me.lblColor.ImageAlign = CType(resources.GetObject("lblColor.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblColor.ImageIndex = CType(resources.GetObject("lblColor.ImageIndex"), Integer)
        Me.lblColor.ImeMode = CType(resources.GetObject("lblColor.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblColor.Location = CType(resources.GetObject("lblColor.Location"), System.Drawing.Point)
        Me.lblColor.Name = "lblColor"
        Me.lblColor.RightToLeft = CType(resources.GetObject("lblColor.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblColor.Size = CType(resources.GetObject("lblColor.Size"), System.Drawing.Size)
        Me.lblColor.TabIndex = CType(resources.GetObject("lblColor.TabIndex"), Integer)
        Me.lblColor.Text = resources.GetString("lblColor.Text")
        Me.lblColor.TextAlign = CType(resources.GetObject("lblColor.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblColor.Visible = CType(resources.GetObject("lblColor.Visible"), Boolean)
        '
        'picColor
        '
        Me.picColor.AccessibleDescription = resources.GetString("picColor.AccessibleDescription")
        Me.picColor.AccessibleName = resources.GetString("picColor.AccessibleName")
        Me.picColor.Anchor = CType(resources.GetObject("picColor.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.picColor.BackgroundImage = CType(resources.GetObject("picColor.BackgroundImage"), System.Drawing.Image)
        Me.picColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.picColor.Dock = CType(resources.GetObject("picColor.Dock"), System.Windows.Forms.DockStyle)
        Me.picColor.Enabled = CType(resources.GetObject("picColor.Enabled"), Boolean)
        Me.picColor.Font = CType(resources.GetObject("picColor.Font"), System.Drawing.Font)
        Me.picColor.Image = CType(resources.GetObject("picColor.Image"), System.Drawing.Image)
        Me.picColor.ImeMode = CType(resources.GetObject("picColor.ImeMode"), System.Windows.Forms.ImeMode)
        Me.picColor.Location = CType(resources.GetObject("picColor.Location"), System.Drawing.Point)
        Me.picColor.Name = "picColor"
        Me.picColor.RightToLeft = CType(resources.GetObject("picColor.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.picColor.Size = CType(resources.GetObject("picColor.Size"), System.Drawing.Size)
        Me.picColor.SizeMode = CType(resources.GetObject("picColor.SizeMode"), System.Windows.Forms.PictureBoxSizeMode)
        Me.picColor.TabIndex = CType(resources.GetObject("picColor.TabIndex"), Integer)
        Me.picColor.TabStop = False
        Me.picColor.Text = resources.GetString("picColor.Text")
        Me.picColor.Visible = CType(resources.GetObject("picColor.Visible"), Boolean)
        '
        'UColor
        '
        Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
        Me.AccessibleName = resources.GetString("$this.AccessibleName")
        Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
        Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
        Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.Controls.Add(Me.picColor)
        Me.Controls.Add(Me.chkColor)
        Me.Controls.Add(Me.lblColor)
        Me.Controls.Add(Me.btnColor)
        Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
        Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
        Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
        Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
        Me.Name = "UColor"
        Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.Size = CType(resources.GetObject("$this.Size"), System.Drawing.Size)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Event ValueChanged As EventHandler

    Private Sub UColor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler picColor.BackColorChanged, AddressOf OnValueChanged
    End Sub

    Private Sub btnColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnColor.Click
        fMain.ColorDialog1.Color = picColor.BackColor
        If fMain.ColorDialog1.ShowDialog(Me) = DialogResult.OK Then
            picColor.BackColor = fMain.ColorDialog1.Color
        End If
    End Sub
    Private Sub chkColor_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkColor.CheckedChanged
        If chkColor.Checked Then
            lblColor.Enabled = False
            picColor.Enabled = False
            btnColor.Enabled = False
        Else
            lblColor.Enabled = True
            picColor.Enabled = True
            btnColor.Enabled = True
        End If
        OnValueChanged(Me, New EventArgs)
    End Sub

    Protected Sub OnValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent ValueChanged(Me, New EventArgs)
    End Sub

    Public Property Color() As Color
        Get
            If chkColor.Checked Then
                Return Color.Transparent
            Else
                Return picColor.BackColor
            End If
        End Get
        Set(ByVal Value As Color)
            If Value.Equals(Color.Transparent) Then
                chkColor.Checked = True
                picColor.BackColor = SystemColors.Control
            Else
                chkColor.Checked = False
                picColor.BackColor = Value
            End If
        End Set
    End Property
    <System.ComponentModel.Localizable(True)> _
    Public Property Caption() As String
        Get
            Return lblColor.Text
        End Get
        Set(ByVal Value As String)
            lblColor.Text = Value
        End Set
    End Property
End Class